//
//  UIButtom+Extension.swift
//  SDAutoWeibo
//
//  Created by 刘健 on 16/3/26.
//  Copyright © 2016年 Clemmie. All rights reserved.
//

import UIKit


extension UIButton {
    
    
    /**
     快速创建按钮
     
     - parameter title:        标题
     - parameter imageName:    图片名称
     - parameter bkgImageName: 背景图片名称
     - parameter textColor:    按钮标题颜色
     - parameter textFont:     按钮标题文字大小
     
     - returns: 按钮
     */
    convenience init(title: String, imageName: String, bkgImageName: String = "timeline_card_bottom_background", textColor: UIColor = UIColor.lightGrayColor(), textFont: CGFloat = 11) {
        self.init()
        
        // 设置
        self.setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        self.setBackgroundImage(UIImage(named: "\(bkgImageName)_highlighted"), forState: UIControlState.Highlighted)
        
        self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(textColor, forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(textFont)
    }
}
